package com.oyesgo.statistics.utils;

import java.util.ResourceBundle;


/**
 * @FileName MailFactory.java
 * @Description: 收件人工厂类
 * @author rose
 * @version 1.0
 * <p>Company: OYESGO</p>
 * <p>Copyright: Copyright (c) 2010</p>
 */
public class MailFactory {
	/**
	 * 加载email资源文件。注意：该资源文件一定要位于src目录下
	 */
	protected static ResourceBundle bundle = ResourceBundle.getBundle("email");
	/**
	 * 邮件发送人
	 */
	public static final String FROM_EMAIL_ADD = bundle.getString("email.from");
	/**
	 *邮件用户
	 */
	public static final String FROM_EMAIL_USER = bundle.getString("email.user");
	/**
	 * 邮件密码
	 */
	public static final String FROM_EMAIL_PWD = bundle.getString("email.pwd");
	/**
	 * 邮件服务器
	 */
	public static final String FROM_EMAIL_SERVICE = bundle.getString("email.service");
	/**
	 * 入库日志地址
	 */
	public static final String FILE_PATH = bundle.getString("file.path");
	/**
	 * 服务器日志文件地址 文件在日期的前部分 例：当一个文件叫4329_20100612_ecclf 则代表4329_
	 */
	public static final String SEVEER_FILE_PATH_START = bundle.getString("file.serverlogpathstart");
	/**
	 * 服务器日志文件地址 文件在日期的后部分 例：当一个文件叫4329_20100612_ecclf 则代表ecclf
	 */
	public static final String SEVEER_FILE_PATH_END = bundle.getString("file.serverlogpathend");
	/**
	 * 服务器日志文件日期格式
	 */
	public static final String SEVEER_FILE_DATE_TYPE = bundle.getString("file.serverlogdatetype");
	
	
	/**
	 * 从资源文件中获取收件人地址
	 * @return String[]
	 */
	public static String[] getEmailAdds(){
		String[] emailStrs = null;
		String emailsString = bundle.getString("emailto.list");
		//如果邮件配置文件有值 则处理逻辑 否则什么都不做
		if(emailsString != null && !"".equals(emailsString.trim())){
			if(emailsString.indexOf(",") < 0) emailStrs = new String[]{emailsString};
			else emailStrs = emailsString.split(",");
		}
		return emailStrs;
	}
	public static void main(String[] args) {
		String[] strs = getEmailAdds();
		for (int i = 0; i < strs.length; i++) {
			System.out.println(strs[i]);
		}
	}
}
